Repository navigation
mingw: use the full buffer when reading reparse points - #6507
VirgilMing wants to merge 1 commit into
Conversation
b1e9fbf to
bdaf6da
Compare
read_reparse_point() limits its UTF-16 to UTF-8 conversion to MAX_PATH bytes, although both callers provide a MAX_LONG_PATH-sized buffer. Since the conversion includes the terminating NUL, symlink targets of 260 or more UTF-8 bytes fail with ERANGE. This affects both readlink() and mingw_lstat(), even for short link paths and with core.longpaths enabled. Use MAX_LONG_PATH for the conversion, matching the buffers allocated by the callers. Add Windows regression coverage for ASCII and multibyte targets of 259, 260 and 261 bytes. Check the decoded target as well as the diff output and stderr, since git diff can report the conversion error without failing its exit status. Disable the filesystem cache so the tests also exercise mingw_lstat(). Fixes: git-for-windows#6498 Co-authored-by: GPT-6 Signed-off-by: vgm <virgilming@gmail.com>
bdaf6da to
b2a0d3a
Compare
|
Rebased this single-commit fix onto current The old run had four cancelled macOS jobs using the unavailable The PR still contains only the original two-file fix and regression tests (43 insertions, 1 deletion). The stable patch ID is unchanged; no workflow changes or test removals were added. Local The new CI, check-style, and check-whitespace workflows were triggered by this update but are awaiting maintainer approval. Could a maintainer please approve the runs so the refreshed branch can be tested? CI run: https://github.com/git-for-windows/git/actions/runs/46155273486 |
This PR fixes #6498.
Before this PR,
read_reparse_point()passesMAX_PATHto the UTF-16-to-UTF-8 conversion, while both callers already allocateMAX_LONG_PATHbytes.The conversion includes the terminating NUL, so the existing code fails with
ERANGE(Result too large) for targets of 260 or more UTF-8 bytes.The failure affects both
readlink()andmingw_lstat()independently ofcore.longpaths; multibyte targets can reach that byte limit with far fewer than 260 characters.MAX_LONG_PATH, matching the buffers that the callers already allocate.t2031-checkout-long-paths.shscript.mingw_lstat()and setcore.longpaths=falseto demonstrate that the short link pathname does not require that option.readlink()truncation behavior remain unchanged.I built the unmodified
maincode (5cf10d74486d1e59b9ae6cedaedb4e26314e1557) and the patched code on native Windows 11 with MSYS2 UCRT64 GCC 16.2.0.I used
DEVELOPER=1,CFLAGS='-O0 -g'andNO_RUST=1, and disabled optional curl, expat, OpenSSL, gettext, iconv, Perl, Python and Tcl/Tk features for these local validation builds.Those build settings are not changes in this PR.
I performed the following checks:
t2031-checkout-long-paths.shsuite against both binaries. Against the unmodified code, four of this PR's new cases fail withResult too largeat 260/261 bytes. Against the patched code, all 14 tests pass with no skips: the seven pre-existing tests, the new setup test and the six new regression cases.t0060-path-utils.sh,t2007-checkout-symlink.sh,t2102-update-index-symlinks.sh,t4011-diff-symlink.shandt7515-status-symlinks.sh. Together, they execute 219 tests successfully and skip 20 according to their prerequisites. This host's shelllnlacks native symlink support; this PR's new regression cases use Windowsmklink, and all six execute successfully.